package com.taotao.portal.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.portal.service.ContentService;
import com.taotao.portal.service.MyOrdersService;


@Controller
public class IndexController {
	
	@Autowired
	private ContentService contentService;
	@Autowired
	private MyOrdersService myOrdersService;

	@RequestMapping("/index")
	public String showIndex(Model model) {
		String adJson = contentService.getContentList();
		model.addAttribute("ad1", adJson);
		
		return "index";
	}
	@RequestMapping("/{page}")
	public String showpage(@PathVariable String page) {
		return page;
	}
	
	/*@RequestMapping("/index")
	public String showIndex() {
		
		return "my-orders";
	}*/
	
	
	@ResponseBody
	@RequestMapping("/order")
	//@CrossOrigin(origins = "*", maxAge = 3600) 
	public String showOrder() {
		String adJosn=myOrdersService.getOrders();
//		model.addAttribute("ord", adJosn);
//		return "test";
		return adJosn;
	}
	
	@RequestMapping(value="httpclient/post",
			method=RequestMethod.POST)
	@ResponseBody
	public String testPost(){
		return "ok";
	}
}
